package com.kly.sc.api.infras.enums;

import com.fqgj.exception.enums.MsgCodeEnum;
import org.springframework.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * 错误码
 */
public enum ErrorCodeEnums implements MsgCodeEnum {

    sign_error(90000, "sign校验异常", HttpStatus.INTERNAL_SERVER_ERROR),
    PARAMS_LACK(10001, "数据缺失", HttpStatus.PAYMENT_REQUIRED),
    TYPE_TRANSFORM_ERROR(10002, "类型转换异常", HttpStatus.PAYMENT_REQUIRED),

    //==============================三方数据==================================
    BIZ_ERROR(50000, "业务异常", HttpStatus.PAYMENT_REQUIRED),
    RISK_ENGINE_DECISION_RESULT_IS_NULL(50001, "决策引擎结果是空", HttpStatus.PAYMENT_REQUIRED),
    CALLBACK_ERROR(50002, "风控结果回调异常", HttpStatus.PAYMENT_REQUIRED),
    RULE_RESULT_LEVEL_ERROR(50003, "风控审核异常", HttpStatus.PAYMENT_REQUIRED),

    PROGRESS_ERROR(50004, "流程出错，无报告生成", HttpStatus.PAYMENT_REQUIRED),
    REPORT_NOT_EXIT(50005, "报告不存在", HttpStatus.PAYMENT_REQUIRED),

    TONGDUN_REPORT_ERROR(60001, "获取同盾数聚魔盒获取统计报告发生异常", HttpStatus.OK),
    TONGDUN_ECOMMERCE_ERROR(60002, "获取同盾电商报告发生异常", HttpStatus.OK),

    PLATFORM_SUBSTRIPTION_RESULT_ERROR(60004, "三方数据订阅结果异常", HttpStatus.PAYMENT_REQUIRED),
    PLATFORM_SUBSCRIPTION_SAVE_DATA_ERROR(60007, "三方数据存储失败", HttpStatus.PAYMENT_REQUIRED);



    private Integer code;
    private String desc;
    private HttpStatus httpStatus;


    private ErrorCodeEnums(Integer code, String desc, HttpStatus httpStatus) {
        this.code = code;
        this.desc = desc;
        this.httpStatus = httpStatus;
    }


    public Map map() {
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("code", code);
        result.put("desc", desc);
        return result;
    }

    public Map map(String message) {
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("code", code);
        if (message != null) {
            result.put("desc", message + desc);
        }
        return result;
    }

    public String toString() {
        return code + ":" + desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public String getMsg() {
        return getDesc();
    }
}
